package com.nightpiter.model.objects;

/**
 * Transition class.
 * 
 * superclass for Transfer and Tunnel classes
 * 
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 * 
 */
public abstract class Transition {
	/**
	 * contains Station from which transition goes
	 */
	protected Station fromStation;
	/**
	 * contains Stations to which transition goes
	 */
	protected Station toStation;

	/**
	 * represents transition duration (in seconds)
	 */
	protected int time;

	/**
	 * public constructor
	 * 
	 * initializes object's fields from parameters
	 * 
	 * @param fromStation
	 * @param toStation
	 * @param time -
	 *            time is seconds between fromStation and toStation
	 */
	public Transition(Station fromStation, Station toStation, int time) {
		this.fromStation = fromStation;
		this.toStation = toStation;
		this.time = time;
		fromStation.addTransition(this);
	}

	/**
	 * @return the Station from which transition goes
	 */
	public Station getFromStation() {
		return fromStation;
	}

	/**
	 * @return the Station to which transition goes
	 */
	public Station getToStation() {
		return toStation;
	}

	/**
	 * @return the time in seconds
	 */
	public int getTime() {
		return time;
	}

	@Override
	public String toString() {
		return "from: " + this.fromStation.getName() + ";  to: "
				+ this.toStation.getName() + ";  time: " + this.time;
	}

}
